(function (lib, config) {
    var loadFunc = function () {
        var wordAry = config.words.split('|'), bgcolorAry = config.bgcolor.split('|').textcolorAry = config.textcolor.split('|');
        /*TODO 方法*/
        var htmlStr = [
            "<style>",
            ".all_mid,.all_mid *{ padding:0; margin:0;}",
            ".all_mid { box-sizing: border-box; -webkit-box-sizing: border-box; margin: 0 auto; font-family: \'微软雅黑\'; font-size: 13px; }",
            ".ly-header { width: 100%;overflow: hidden; padding-bottom: 0;position:relative; background:#2e2e32;}",
            ".ly-header div { height: 40px; background: #393a3f; overflow:hidden; }",
            ".ly-header a{ vertical-align:top;}",
            ".ly-header div a i { float: right; width: 1px; height: 20px; margin: 10px 0 0 0;}",
            ".ly-header div p { color: #FFF; font-size:16px; height: 40px; line-height: 40px; margin:0; background:{{bgcolor}};}",
            ".ly-header div a:nth-child(2) { float: right; width: 50px; line-height:40px; text-align:center; font-size:30px; color:#fff; height: 40px; background:#2E2E32; }",
            ".ly-section1 { background: #ebebeb; padding: 1px 0 5px 0; }",
            ".ly-section1 .db-line { margin: 0 0 0 10px; }",
            ".ly-section1 .left { float: left; max-width: 90%; margin: 4px 0 0 0; }",
            ".ly-section1 .left div { position: relative; margin: 0 0 0 55px; padding: 5px; background: #FFF; color: #323232; border: 1px solid #d5d5d5; border-radius: 6px; }",
            ".time { font-size: 13px; color: #fff; text-align: center; margin-top: 5px; margin-left: 45%; border-radius: 3px; width:60px; height: 20px; line-height: 20px; background: #ccc; overflow: hidden; }",
            ".ly-section1 .left div i { position: absolute; top: 2px; left: -20px; width: 20px; height: 20px; background: url(/images/wechat.png) no-repeat scroll 0 -200px; transform: rotate(-180deg) }",
            ".ly-section1 .left img { float: left; margin: 0px 2px 0 0; border-radius:50%;width:auto; }",
            ".ly-section1 .left div img { float: none; width: 24px; }",
            ".ly-section1 figure { width: 95%; margin: 3px auto; overflow: hidden; border-bottom: 1px solid #CCCCCC; }",
            ".ly-section1 .zzh { width: 100%; float: left; display: block; margin-bottom: 15px; }",
            ".ly-section1 figcaption { width: 68%; float: left; margin-left: 2%; }",
            ".ly-footer {width: 100%; height: 50px; background: #FFF; border-top: 1px solid #bfbfbf }",
            ".ly-footer .azf1 a { float: left; width: 50px; height: 50px; background: url(/images/wechat.png) no-repeat scroll 9px -89px; }",
            ".ly-footer .azf2 textarea { float: left; width: 82%; height: 36px; margin: 7px 0 0 0px; color: #000; font-size: 13px; line-height: 35px; border: none; border-bottom: 1px solid #d8d8d8; transition: 0.3s; resize: none; outline: none; }",
            ".ly-footer .azf2 textarea:focus { border: none; border-bottom: 1px solid #45c01a; }",
            ".ly-footer .azf2 textarea.on { border-bottom: #45c01a }",
            ".ly-footer .azf2 i { }",
            ".ly-footer .azf1{  width: 50px; float:left}",
            ".ly-footer .azf2{ width: 63%; float: left;  }",
            ".ly-footer .azf3  {   width: 67px; float:right }",
            ".ly-footer .azf3 a { float: right; margin-right: 10px; width:58px; height: 35px; margin-top: -40px; margin: 7px 5px 0 0; background: #45c01a; color: #FFF; text-align: center; line-height: 35px; border-radius: 5px; cursor: pointer; transition: 0.3s; }",
            ".ly-footer .azf3 a:hover { background-color: #3aa814; }",
            ".ly-clear { clear: both; }",
            ".ly-hide { display: none; }",
            ".ly-animation-bell { display: inline-block; color: #F00; transition: 0.5s; }",
            ".ly-animation-bell.on { animation: ly-animation-bell 0.5s; }",
            "#pfjw { width: 100%; z-index: 9999999; left: 0; bottom: 0; position: fixed; display: none; }",
            "#pfjw .closePop { line-height: 35px; font-size: 30px; text-decoration: none; color: #fff; text-align: center; float: left; width: 50px; height: 40px; background: url(/images/wechat.png) no-repeat 20px 12px; }",
            "#pfjw .closePop img { margin: 2px auto; display: block; }",
            "@keyframes ly-animation-bell { 0% {",
            "transform:rotate(-5deg);",
            "}",
            "20% {",
            "transform:rotate(10deg);",
            "}",
            "40% {",
            "transform:rotate(-15deg);",
            "}",
            "60% {",
            "transform:rotate(20deg);",
            "}",
            "80% {",
            "transform:rotate(-15deg);",
            "}",
            "100% {",
            "transform:rotate(10deg);",
            "}",
            "}",
            "#LRfloater1 { z-index: 99999!important }",
            "}",
            "",
            "</style>",
            "",
            "",
            "<div class=\'all_zx\' id=\'pfjw\'>",
            "    <div class=\'all_mid\'>",
            "        <div class=\'ly-header\'><a onclick=\'toolclose();\' class=\'closePop\'></a>",
            "            <div><a><i></i></a><a onclick=\'toolclose();\'>×</a>",
            "                <p>{{dotname}}</p>",
            "            </div>",
            "        </div>",
            "        <div id=\'toopl\' class=\'shadow\'></div>",
            "        <div class=\'ly-section1\' id=\'frist\'>",
            "            <div id=\'now44\' class=\'time\'></div>",
            "            <dl id=\'tools3\'>",
            "                <div class=\'db-line ly-hide\' style=\'display: block; opacity: 1.08347;\'>",
            (function(){
                var wordTemplate = [
                    "                    <div class=\'left\'><img src=\'{{imglink}}\' style=\'width:40px;\'>",
                    "                        <div><i></i>{{str}}</div>",
                    "                    </div>"].join('');
                var outList=[];
                for(var i=0;i<wordAry.length;i++){
                    outList[i]=lib.util.resolveTemplate(wordTemplate,'imglink',config.imglink,'str',wordAry[i]);
                }
                return outList.join('');
            })(),
            "                    <div class=\'ly-clear\'></div>",
            "                </div>",
            "            </dl>",
            "        </div>",
            "        <div style=\'padding:0;margin-top: 0;margin-bottom: 0px;\' class=\'ly-footer\'>",
            "            <div class=\'azf1\'><a href=\'javascript:void(0);\' onclick=\"openZoosUrl('{{identifier}}')\"></a></div>",
            "            <div class=\'azf2\'>",
            "                <a href=\'javascript:void(0);\' onclick=\"openZoosUrl('{{identifier}}')\"><textarea id=\'xiu\' onclick=\"openZoosUrl('{{identifier}}')\" class=\'textareathis container\'>请</textarea></a>",
            "                <i></i></div>",
            "            <div class=\'azf3\'><a href=\'javascript:void(0);\' onclick=\"openZoosUrl('{{identifier}}')\">发送</a></div>",
            "        </div>",
            "    </div>",
            "</div>"
        ].join('');

        function nowTime(_obj) {
            var now = new Date();
            var hh = now.getHours();
            var mm = now.getMinutes();
            var ss = now.getSeconds();

            function getDateWeek(obj) {
                if (obj < 10) return "0" + obj; else return obj;
            }

            _obj.innerHTML = getDateWeek(hh) + ":" + getDateWeek(mm) + ":" + getDateWeek(ss);
        }

        var date2 = document.getElementById("now44");
        setTimeout(function () {
            nowTime(date2);
        }, 2000);

        var frist = document.getElementById("pfjw");
        var toopl = document.getElementById("toopl");
        var tools3 = document.getElementById("tools3");
        setTimeout("toolshow()", config.firsttime*1000);
        toolshow = function () {
            frist.style.display = "block";
            var screenheight = window.screen.height;
            if (screenheight <= 480) {
                var allmid = document.getElementsByClassName('all_mid')[0];
                allmid.style.cssText = "font-size:12px !important;";
            }
            ;

        };
        toolshow3 = function () {
            tools3.style.display = "block";
        };
        toolclose = function () {
            frist.style.display = "none";
            toopl.style.display = "none";
            if(+config.relapsetime>0)setTimeout("toolshow()", config.relapsetime*1000);
        };
        var s = '请输入您想要咨询的问题...';
        var con = document.getSelection('container');
        var index = 0;
        var length = s.length;
        var tId = null;

        function startshuru() {
            con.text('');
            con.append('<span></span>');
            tId = setInterval(function () {
                    con.append(s.charAt(index));
                    if (index++ === length) {
                        clearInterval(tId);
                        index = 0;
                        startshuru()
                    }
                },
                400);
        }
        startshuru();
        $("#xiu").focus(function () {
            $(this).val('');
        });
    };
    lib.load(loadFunc);
    /*执行代码*/
})('{{lib}}', '{{config}}');